package com.xiaoxiong.mami.dao.mapper;

import com.xiaoxiong.mami.dao.daomain.UserToken;
import org.apache.ibatis.jdbc.SQL;

public class UserTokenSqlProvider {

    public String insertSelective(UserToken record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("user_token");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getToken() != null) {
            sql.VALUES("token", "#{token,jdbcType=VARCHAR}");
        }
        
        if (record.getUserId() != null) {
            sql.VALUES("userId", "#{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getRefreshToken() != null) {
            sql.VALUES("refreshToken", "#{refreshToken,jdbcType=VARCHAR}");
        }
        
        if (record.getExpireTime() != null) {
            sql.VALUES("expireTime", "#{expireTime,jdbcType=BIGINT}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("updateTime", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("createTime", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(UserToken record) {
        SQL sql = new SQL();
        sql.UPDATE("user_token");
        
        if (record.getToken() != null) {
            sql.SET("token = #{token,jdbcType=VARCHAR}");
        }
        
        if (record.getUserId() != null) {
            sql.SET("userId = #{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getRefreshToken() != null) {
            sql.SET("refreshToken = #{refreshToken,jdbcType=VARCHAR}");
        }
        
        if (record.getExpireTime() != null) {
            sql.SET("expireTime = #{expireTime,jdbcType=BIGINT}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("updateTime = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("createTime = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}